//package com.zmn.plat.dubbo.impl.product.item;
//
//import com.zmn.common.dto.VtDTO;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.common.dictionary.PlatErrorCodeDict;
//import com.zmn.plat.dubbo.interfaces.product.item.ItemCategoryListRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.service.category.ItemCategory;
//import com.zmn.plat.services.interfaces.service.category.ItemCategoryService;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.StringUtils;
//import org.apache.dubbo.config.annotation.Service;
//import org.springframework.util.CollectionUtils;
//
//import javax.annotation.Resource;
//import javax.validation.Valid;
//import javax.validation.constraints.NotNull;
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.List;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * @author tanghongjun
// * @version v1.0 @类说明： 服务项类型dubbo实现类
// * @since 2020年8月4日10:53:32
// */
//@Slf4j
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//public class ItemCategoryListRemoteServiceImpl implements ItemCategoryListRemoteService {
//
//    @Resource
//    protected ItemCategoryService faultCategoryService;
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<VtDTO> getDescVtById(@NotNull(message = "入参不能为空") @Valid Integer categId) {
//        log.info("getDescVtById：categId={}", categId);
//        ItemCategory faultCategory = faultCategoryService.findByKey(categId);
//        if (Objects.isNull(faultCategory) || StringUtils.isEmpty(faultCategory.getDesc())) {
//            log.error("faultCategory or desc is null.errorCode:{}", PlatErrorCodeDict.ERROR_CODE_PRODUCT_ITEM_OR_REMARK_NOT_EXIT);
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PRODUCT_ITEM_OR_REMARK_NOT_EXIT);
//        }
//        return ResponseDTO.success(new VtDTO(categId, faultCategory.getDesc()));
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<VtDTO>> listDescVtByIdList(@NotNull(message = "入参不能为空") @Valid List<Integer> categIdList) {
//        log.info("listDescVtByIdList：categIdList={}", categIdList);
//
//        List<ItemCategory> faultCategories = faultCategoryService.listByKeys(categIdList);
//        if (CollectionUtils.isEmpty(faultCategories)) {
//            log.error("faultCategories is empty.errorCode:{},categIdList:{}", PlatErrorCodeDict.ERROR_CODE_PRODUCT_ITEM_CATEGORY_NOT_EXIT, categIdList);
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PRODUCT_ITEM_CATEGORY_NOT_EXIT);
//        }
//
//        List<VtDTO> dtos = faultCategories.stream().filter(e -> StringUtils.isNotEmpty(e.getDesc())).map(e -> new VtDTO(e.getCategId(), e.getDesc())).collect(Collectors.toList());
//
//        if (CollectionUtils.isEmpty(dtos)) {
//            log.error("dtos is empty.errorCode:{}", PlatErrorCodeDict.ERROR_CODE_PRODUCT_ITEM_REMARK_NOT_EXIT);
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PRODUCT_ITEM_REMARK_NOT_EXIT);
//        }
//
//        return ResponseDTO.success(dtos);
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<VtDTO>> listVtByBizTypeList(List<Integer> bizTypeList) {
//        List<ItemCategory> faultCategories = faultCategoryService.listAll();
//        faultCategories = faultCategories.stream().filter(e->bizTypeList.contains(e.getBizType())).collect(Collectors.toList());
//        List<VtDTO> list = new ArrayList<>();
//        if(!CollectionUtils.isEmpty(faultCategories)){
//            list.addAll(faultCategories.stream().map(e->new VtDTO(e.getCategId(),e.getCategName())).collect(Collectors.toList()));
//
//        }
//        return ResponseDTO.success(list);
//
//    }
//}
